package controller

import (
	"zzxq/common/codes"
	"zzxq/common/middleware/response"
	"zzxq/service"

	"github.com/gin-gonic/gin"
)

type Tag struct {

}

//获取全部tag（包含用户+系统标签）
func (tag *Tag) GetUserTags(c *gin.Context) {
	uid := c.GetInt("uid")
	tagService := &service.TagService{}

	tags := tagService.GetUserAllTage(uid)

	// codes.RespS(c, tags)
	res := response.NewResponse(c)
	res.Resp(codes.SUCCESS, res.WithData(tags))
}

//创建用户自定义tag
func (tag *Tag) CreateUserTag(c *gin.Context) {
	uid := c.GetInt("uid")
	title, ok := c.GetPostForm("title")
	if !ok {
		response.RespF(c, 3000, "参数异常")
		return
	}

	tagService := &service.TagService{}
	tagService.CreateUserTag(uid, title)

	response.RespS(c, nil)
}